package com.su.ch.utils;

import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;

public class XmppTool {

	private static XMPPConnection conn = null;
	private static String address = "192.168.0.1";
	private static int port = 5222;

	public static void openConnection() throws XMPPException {
		// Properties prop = new Properties();

		ConnectionConfiguration configuration = new ConnectionConfiguration(
				address, port);
		conn = new XMPPConnection(configuration);
		conn.connect();
	}

	public static XMPPConnection getConnection() {
		try {
			if (conn == null)
				openConnection();
			return conn;
		} catch (XMPPException e) {
			e.printStackTrace();
			return null;
		}
	}

	public static void closeConnection() {
		if (conn != null) {
			conn.disconnect();
			conn = null;
		}
	}

}